home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / sml_nj / 93src.lha / src / debug / timedlog.sml < prev    next >
Encoding:
Text File  |  1993-01-27  |  1.0 KB  |  39 lines

  1. signature TIMED_LOG =
  2. sig
  3.   type time
  4.   exception Logtime of time (* found *) * time (* desired *)
  5.   include LOG
  6.   (* All basic operations are the same, but entries are tagged with times;
  7.      if there is a mismatch, Time is raised.
  8.      Additional function: *)
  9.   val next: mark -> (time * entry)
  10.       (* Like read, but returns the time rather than checking it. *)
  11. end
  12.  
  13. functor TimedLog(type entry) : TIMED_LOG =
  14. struct
  15.   open DebugKernel
  16.   type basicEntry = entry
  17.   structure Log = Log(type entry=time * basicEntry)
  18.   open Log
  19.   exception Logtime of time * time
  20.   type entry = basicEntry
  21.   fun append m x = Log.append m (currentTime(),x)
  22.   fun get m = 
  23.     let val (t,x) = Log.get m
  24.     in if t <> currentTime() then
  25.          raise Logtime(t,currentTime())
  26.        else x
  27.     end
  28.   fun read m = 
  29.     let val (t,x) = Log.read m
  30.     in if t <> currentTime() then
  31.          raise Logtime(t,currentTime())
  32.        else x
  33.     end
  34.   val next = Log.read
  35.   fun replace m x = Log.replace m (currentTime(),x)
  36.   fun write m x = Log.write m (currentTime(),x)
  37. end
  38.  
  39.